package tech.aistar.service.impl;


import org.apache.ibatis.session.SqlSession;
import tech.aistar.entity.PhoneType;
import tech.aistar.mapper.PhoneTypeMapper;
import tech.aistar.service.IPhoneTypeService;
import tech.aistar.util.MybatisUtil;

import java.util.List;

public class PhoneTypeServiceImpl implements IPhoneTypeService{


    @Override
    public List<PhoneType> findAll() {
        SqlSession sqlSession = MybatisUtil.getSqlSession();
        PhoneTypeMapper mapper = sqlSession.getMapper(PhoneTypeMapper.class);

        List<PhoneType> list = mapper.findAll();

        MybatisUtil.close(sqlSession);

        return list;
    }

    @Override
    public PhoneType findById(Integer id) {
        SqlSession sqlSession = MybatisUtil.getSqlSession();
        PhoneTypeMapper mapper = sqlSession.getMapper(PhoneTypeMapper.class);

       PhoneType phoneType = mapper.findById(id);

        MybatisUtil.close(sqlSession);

        return phoneType;
    }
}
